package chapter9_Buffer;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.ObjectOutputStream;
import java.io.OutputStreamWriter;

public class ObjectOutputTest {
    public static void main(String[] args) {
        try {
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream("C:\\Users\\WYH\\Desktop\\java11.txt"));
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream("C:\\Users\\WYH\\Desktop\\java1.txt"), "UTF-8"));

            String s = "";
            while ((s = bufferedReader.readLine()) != null) {
                String[] strArray = s.split("\t");
                Student stu = new Student(strArray[0], strArray[1], Integer.parseInt(strArray[2]));
                objectOutputStream.writeObject(stu);
            }

            bufferedReader.close();
            objectOutputStream.flush();
            objectOutputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}